<template>
  <div class="xchange-body">
    <div class="line first"><p>此价格为现金买卖价格，仅供参考</p></div>
    <div class="line header">
      <span>名称</span>
      <span>买入价</span>
      <span>价格</span>
    </div>
    <div v-for="item in dataList" :key="item.id">
      <div class="line item" :style="selected === item.id ? 'background:#eee': ''" @click="handleClickItem(item.id)">
        <div>
          <span>{{ item.utilStr }}</span>
          <span>{{ item.util }}</span>
        </div>
        <span>{{ item.price1 }}</span>
        <span>{{ item.price2 }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  mounted() {
    this.dataList = [
      { id: 0, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 1, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 2, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 3, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 4, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 5, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 6, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 7, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 8, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 9, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 10, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 11, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
      { id: 12, util: "RMB", utilStr: "人民币", price1: 0.918, price2: 0.91 },
      { id: 13, util: "GBP", utilStr: "英镑", price1: 0.918, price2: 0.91 },
    ];
  },
  data() {
    return {
      dataList: [],
      selected: -1,
    };
  },
  methods: {
    handleClickItem(id) {
      this.selected = id
      console.log('this.selected', id);
    }
  },
};
</script>

<style lang="scss" scoped>
.xchange-body {
  display: flex;
  flex-direction: column;
  margin-top: 46px;
  text-align: start;
  .line {
    border-bottom: 1px solid #f1f1f1;
    padding: 16px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .first {
    background: #f9f9f9;
    font-size: 14px;
    font-family: PingFang TC;
    color: #333333;
    justify-content: start;
  }
  .header {
    span {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #888888;
    }
  }
  .item {
    div {
      display: flex;
      flex-direction: column;
      width: 40px;
      span:first-child {
        font-size: 13px;
        color: #333333;
      }
      span:nth-child(2) {
        font-size: 12px;
        font-family: Source Han Sans CN;
        color: #888;
        line-height: 16px;
      }
    }
  }
}
</style>